﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsInvestors
    {
        public static List<Investors> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.Investors.Select(db);
            }
            
        }

        public static void Insert(Investors capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<Investors>(capital, EnumSaveMode.Requery);
            }
            
        }

        public static void Update(Investors capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<Investors>(capital);
            }
            
        }

        public static Investors SelectByPk(Int32 capId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Investors>(string.Format("InvID={0}", capId));
            }
            
        }

        public static Investors SelectByCode(string invCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Investors>(string.Format("InvCode='{0}'", invCode));
            }
            
        }

        public static int DeleteByPk(Int32 capId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<Investors>(string.Format("InvID={0}", capId));
            }
            
        }
    }
}
